package com.cykj.controller;

import com.cykj.service.RoleService;
import com.cykj.util.ResponseDto;
import com.cykj.vo.PageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/role")
public class RoleController {
    @Autowired
    private RoleService roleService;

    @RequestMapping("/getAllRoles")
    public ResponseDto getAllRoles(@RequestBody PageVo vo){
        ResponseDto dto = roleService.getAllRoles(vo.getPageCurr(), vo.getPageSize());
        return dto;
    }

    @RequestMapping("/getPermissionMenu")
    public ResponseDto getPermissionMenu(int roleId){
        return  roleService.getPermissionMenu(roleId);
    }

    @RequestMapping("/addPermission")
    public ResponseDto addPermission(int menuId,int roleId){
        return roleService.addPermission(menuId, roleId);
    }
    @RequestMapping("/deletePermission")
    public ResponseDto deletePermission(int menuId,int roleId){
        return roleService.deletePermission(menuId, roleId);
    }
}
